package com.yanqu.road.server.cmd.activity.hsisland;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HsIslandProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandActivity;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandActivityMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C2_HS_ISLAND_UNLOCK_IMAGE_BF_SCORE, desc = "海神岛-解锁形象，补发积分")
public class CrossHsIslandUnlockImageBfScoreCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        HsIslandProto.HsIslandUnlockImageBfScoreCrossReqMsg reqMsg = HsIslandProto.HsIslandUnlockImageBfScoreCrossReqMsg.parseFrom(packet.getBytes());
        CrossHsIslandActivity activity = CrossHsIslandActivityMgr.getActivity(reqMsg.getActivityId(), groupId);
        if (activity == null) {
            return;
        }
        //存储userBase
        if(reqMsg.hasUserInfo()){
            UserBaseInfo userBaseInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getUserInfo());
            CrossUserMgr.updateUserBaseInfo(packet.getPlayerId(), userBaseInfo);
        }
        //解锁形象，补发积分
        activity.unlockImageBfScore(packet.getPlayerId());
    }

    @Override
    public void sendData() {}
}
